package com.cooksys.film_rental.bo.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cooksys.film_rental.bo.StaffBo;
import com.cooksys.film_rental.dao.StaffDao;
import com.cooksys.film_rental.model.Address;
import com.cooksys.film_rental.model.Payment;
import com.cooksys.film_rental.model.Rental;
import com.cooksys.film_rental.model.Staff;
import com.cooksys.film_rental.model.Store;

@Service("StaffBo")
public class StaffBoImpl implements StaffBo {

	@Autowired(required = true)
	StaffDao staffDao;

	@Override
	public Staff getStaffByStaffId(Byte staffId) {
		return this.staffDao.getStaffByStaffId(staffId);
	}

	@Override
	public Staff getStaffByStaffId(String staffId) {
		try {

			Byte staffIdAsByte = Byte.valueOf(staffId);
			return this.getStaffByStaffId(staffIdAsByte);

		} catch (NumberFormatException e) {

			System.err
					.println("Could not parse Byte value for staffId from string: "
							+ staffId);
			e.printStackTrace();
			System.err.println("Returning null value...");
			return null;

		}
	}

	@Override
	public List<Staff> searchStaffByAddress(Address address) {
		return this.staffDao.searchStaffByAddress(address);
	}

	@Override
	public List<Staff> searchStaffByStore(Store store) {
		return this.staffDao.searchStaffByStore(store);
	}

	@Override
	public Staff getStaffByRental(Rental rental) {
		return this.staffDao.getStaffByRental(rental);
	}

	@Override
	public Staff getStaffByPayment(Payment payment) {
		return this.staffDao.getStaffByPayment(payment);
	}

	@Override
	public Staff getStaffByStore(Store store) {
		return this.staffDao.getStaffByStore(store);
	}

}
